﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TRINHTUNGLAM
{
    public partial class Form6 : Form
    {
        public Form6()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            /*if(string.IsNullOrEmpty(txta.Text))
            {
                errorProvider1.SetError(txta, "yeu cau nhap vao so a");
            }
            else if (string.IsNullOrEmpty(txtb.Text))
            {
                errorProvider1.SetError(txtb, "yeu cau nhap vao so b");
            }
            else if (string.IsNullOrEmpty(comboBox1.Text))
            {
                errorProvider1.SetError(comboBox1, "yeu cau nhap vao phep tinh");
            }
            //String cmb = this.comboBox1.SelectedItem.ToString();
            else
            {
                double a = 0;
                double b = 0;
                if (double.TryParse(txta.Text, out a) && double.TryParse(txtb.Text, out b))
                {
                    if (comboBox1.SelectedIndex.ToString().Equals("Cong"))
                    {
                        listBox1.Items.Add(a + b);
                    }
                    if (cmb == "Tru")
                    {
                        listBox1.Items.Add(a - b);
                    }
                    if (cmb == "Nhan")
                    {
                        listBox1.Items.Add(a * b);
                    }
                    if (cmb == "Chia")
                    {
                        listBox1.Items.Add(a / b);
                    }
                }
                else
                {
                    errorProvider1.SetError(txta.Text, "gia tri ko hop le");
                    txta.Focus();
                    txtb.Focus();
                }
            }*/
        }
    }
}
